import React from 'react'

import { Upload, message } from 'antd';

import style from './style.module.css'
// import axios from 'axios'



const killList = (props) => {

  let { AddUpload } = props

  const propslist = {
    name: 'file',
    action: '/api/upload',
    headers: {
      authorization: 'authorization-text',
    },
    // 点击上传图片
    onChange(info) {
      // 判断
      if (info.file.status !== 'uploading') {
        // 拿到图片的路径
        AddUpload(info.file.response.imgUrl)
      }
      //判断上传是否成功 
      if (info.file.status === 'done') {
        message.success(`${info.file.name} 上传成功`);
      } else if (info.file.status === 'error') {
        message.error(`${info.file.name} 上传失败`);
      }
    },
  }
  return <div className={style.firstBox}>
    <div className={style.firstBoxHeader}>
      <span>选择商品图片：</span>
      <div className={style.firstBoxIcon} >
        <Upload
          {...propslist}
        >
          <div className={style.addImg}>+</div>
        </Upload>
      </div>
    </div>


  </div>
}

export default killList